/*
 * Copyright 2008 Google Inc.
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <sys/types.h>

/* Same as MAX_STRING_LEN in Apache. */
#define GVN_USERDB_MAX_LINE_LEN 8192

/* Return the length of the password file name for userdb_path and user.
   The length includes space for a terminating null byte. */
size_t
gvn_userdb_password_filename_length(const char *userdb_path,
                                    const char *user);

/* Store in filename the the file name for userdb_path and user.

   filename must be at least as large as the size returned by
   gvn_userdb_password_filename_length(userdb_path, user).  filename will
   include a terminating null byte. */
void
gvn_userdb_password_filename(char *filename,
                             const char *userdb_path,
                             const char *user);

/* Return the password from filename, or NULL on error.

   Errors include the user not existing.  The return value is a pointer
   into buf, with a null byte written into buf at the end of the result. */
char *
gvn_userdb_password(const char *filename, char *buf);
